|
Technote 1063Inside Macintosh: Processes, Time Manager AddendaBy Eric Simenel |
CONTENTSSome Basic Time Manager
Rules |
This technote discusses a number of Time Manager issues that are not covered in the Time Manager chapter of Inside Macintosh: Processes. This Note is intended for all developers who want to do time measurement using the Time Manager routines. |
Some Basic Time Manager RulesWhen programming with the Time Manager, it is important to observe the following rules.
This rules are not new; they are all explicitly or implicitly described in Inside Macintosh: Processes. However, recent systems now enforce these rules more strictly. If you break these rules, you may see one of the following symptoms.
|
Setting Up tmReservedOn page 3-8 of
Inside Macintosh: Processes, it clearly states
that both
If you do want to do some time measurement, then you have
to call The truth is that prior to October, 1992 (System Software 7.1), you didn't care, but it's more of a concern now, since Apple slightly modified the behavior of the Time Manager to deal with performance issues. If you leave
for some good but can't-be-disclosed reason, your
extended time task is converted into a non-extended time
task which, being waked up with a 0 delay
So, if you perform that kind of time measurement, be sure to write instead:
Since the Time Manager, prior to System Software 7.1,
doesn't care about |
About tmWakeUpThe following sentence, also on page 3-8 in Inside
Macintosh: Processes, is incorrect: "The
|
Undeferred Time Manager TasksThis section describes an optimization that you might want to employ when using the Time Manager in the presence of virtual memory (VM). Most developers will not be interested in this; however, all users of the Time Manager should heed the following warning.
As described in Inside Macintosh: Memory, Time Manager tasks are automatically deferred by the Virtual Memory (VM) system to avoid fatal page faults. This was done for backward compatibility with existing applications that use the Time Manager, but it can seriously increase the latency between when the timer expires and when your Time Manager task executes. For more information about interactions between the Time Manager and VM, see Technote 1094, "Virtual Memory Application Compatibility." For example, if you schedule a Time Manager task to execute at time X and, at time (X - delta) some process takes a page fault, your Time Manager task will not be called until time (X + Y - delta), where Y is the time required to field a page fault. If the page fault causes the hard disk to seek, Y could be as great as the hard disk's average seek time, approximately 10 ms. If you are trying to use the Time Manager to measure time in microseconds, this could be a problem. There is a way you can install Time Manager tasks so the callback is not deferred by VM; however, before using this technique, you should be aware of its dangers. Because VM does not defer these special Time Manager tasks, it is possible for them to fire when paging is not safe. To avoid fatal page faults, you must ensure:
If you call |
The Microseconds AlternativeAnother way to perform time measurement would be to use
the
|
SummaryThe following points explain what you should and should not do in working with the Time Manager:
|
Change History
DownloadablesAcknowledgmentsThanks to Brian Bechtel, Bob Bradley, Drew Colace, Jim Luther, Denis G. Pelli, Geoff Stahl, and Bob Wambaugh. |